<?php

namespace App\Events\Kms;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class GroupShareEvent
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public array  $groupIds;
    public array  $resourceIds;
    public int    $mid;
    public string $comment;
    public array  $shareUser;

    /**
     * @param array $groupIds 群组id
     * @param array $resourceIds 资源id
     * @param int $mid 资源主表id
     * @param string $comment 评论
     * @param array $shareUser 分享用户信息
     */
    public function __construct(array $groupIds, array $resourceIds, int $mid, string $comment, array $shareUser)
    {
        $this->groupIds    = $groupIds;
        $this->resourceIds = $resourceIds;
        $this->mid         = $mid;
        $this->comment     = $comment;
        $this->shareUser   = $shareUser;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return Channel
     */
    public function broadcastOn()
    {
        return new PrivateChannel('channel-name');
    }
}
